<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Discontinuous Galerkin: /home/ronaldo/workspace/DiscontinuousGalerkin/SquareTriangularGrid.f90 Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">Discontinuous Galerkin
   &#160;<span id="projectnumber">0.0.01</span>
   </div>
   <div id="projectbrief">Teste</div>
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Types&#160;List</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('_square_triangular_grid_8f90.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">/home/ronaldo/workspace/DiscontinuousGalerkin/SquareTriangularGrid.f90</div>  </div>
</div>
<div class="contents">
<a href="_square_triangular_grid_8f90.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a><a class="code" href="class_square_triangular_grid_manipulation.html">00001</a> <span class="keyword">module</span> <a class="code" href="class_square_triangular_grid_manipulation.html">SquareTriangularGridManipulation</a>
<a name="l00002"></a>00002     use <span class="keywordflow">TriangleElementManipulation</span>
<a name="l00003"></a>00003     <span class="keyword">implicit none</span>
<a name="l00004"></a>00004 
<a name="l00005"></a>00005 
<a name="l00006"></a><a class="code" href="class_square_triangular_grid_manipulation.html#ab2ed4fba88e8621e49ae15ae663a150e">00006</a>         <span class="keywordtype">integer</span>, <span class="keywordtype">parameter</span> :: numberOfBoundaries = 4
<a name="l00007"></a>00007 
<a name="l00008"></a><a class="code" href="class_square_triangular_grid_manipulation.html#a0637d6645ecf5fdadf2ef9118b38ff13">00008</a>         <span class="keywordtype">integer</span>, <span class="keywordtype">parameter</span> :: prescribedTemperatureBoundary = 1
<a name="l00009"></a><a class="code" href="class_square_triangular_grid_manipulation.html#ae28f879bdae6d228ca48dbd896ad1d9b">00009</a>         <span class="keywordtype">integer</span>, <span class="keywordtype">parameter</span> :: prescribedHeatFluxBoundary = 2
<a name="l00010"></a><a class="code" href="class_square_triangular_grid_manipulation.html#a1d0afd6e725f6fa9d00be7a487e0c160">00010</a>         <span class="keywordtype">integer</span>, <span class="keywordtype">parameter</span> :: convectionBoundary = 3
<a name="l00011"></a>00011 
<a name="l00012"></a><a class="code" href="class_square_triangular_grid_manipulation.html#ad9a216a465778c32b6163578213c8b7b">00012</a>         <span class="keywordtype">real(kind=8)</span>, <span class="keywordtype">parameter</span> :: MaximumError = 1.0d-6
<a name="l00013"></a>00013 
<a name="l00014"></a><a class="code" href="class_square_triangular_grid_manipulation.html#a5302613ea040f784475941c2a300a705">00014</a>     <span class="keywordtype">integer</span>, <span class="keywordtype">parameter</span> :: MaxSteps = 100000
<a name="l00015"></a>00015 
<a name="l00016"></a><a class="code" href="struct_square_triangular_grid_manipulation_1_1_square_triangular_grid.html">00016</a>     <span class="keyword">type</span> <a class="code" href="struct_square_triangular_grid_manipulation_1_1_square_triangular_grid.html">SquareTriangularGrid</a>
<a name="l00017"></a><a class="code" href="struct_square_triangular_grid_manipulation_1_1_square_triangular_grid.html#a8874fac92f29edc7b234c27b3d16c634">00017</a>         <span class="keywordtype">integer</span> :: Nelx
<a name="l00018"></a><a class="code" href="struct_square_triangular_grid_manipulation_1_1_square_triangular_grid.html#a596ce4eaabc9af0273730daffe68a34f">00018</a>         <span class="keywordtype">integer</span> :: Nely
<a name="l00019"></a>00019 
<a name="l00020"></a><a class="code" href="struct_square_triangular_grid_manipulation_1_1_square_triangular_grid.html#a84e26b38bf8f5ab5e390afefe2c9aee4">00020</a>         <span class="keywordtype">real(kind=8)</span> :: Lx
<a name="l00021"></a><a class="code" href="struct_square_triangular_grid_manipulation_1_1_square_triangular_grid.html#afeef9c254e9448275b8141860bed82c7">00021</a>         <span class="keywordtype">real(kind=8)</span> :: Ly
<a name="l00022"></a>00022 
<a name="l00023"></a><a class="code" href="struct_square_triangular_grid_manipulation_1_1_square_triangular_grid.html#a4db17ff464400eb5added678a4dc5217">00023</a>         <span class="keywordtype">real(kind=8)</span> :: Basex
<a name="l00024"></a><a class="code" href="struct_square_triangular_grid_manipulation_1_1_square_triangular_grid.html#a59c0ff89d5d351f49eba25e25f3d4add">00024</a>         <span class="keywordtype">real(kind=8)</span> :: Basey
<a name="l00025"></a>00025 
<a name="l00026"></a><a class="code" href="struct_square_triangular_grid_manipulation_1_1_square_triangular_grid.html#abedfc391180d41b3826ad1742f39ad51">00026</a>         <span class="keywordtype">type(TriangleElement)</span>, <span class="keywordtype">dimension(:)</span>, <span class="keywordtype">allocatable</span> :: Elements
<a name="l00027"></a><a class="code" href="struct_square_triangular_grid_manipulation_1_1_square_triangular_grid.html#a709879b3ce5ae67c75d7a43c4b775b17">00027</a>         <span class="keywordtype">real(kind=8)</span>, <span class="keywordtype">dimension(:,:)</span>, <span class="keywordtype">allocatable</span>        :: Nodes
<a name="l00028"></a><a class="code" href="struct_square_triangular_grid_manipulation_1_1_square_triangular_grid.html#a8f77b97d0392db5163a1f5ebbdd7037e">00028</a>         <span class="keywordtype">integer</span>, <span class="keywordtype">dimension(:,:)</span>, <span class="keywordtype">allocatable</span>             :: Neighbours <span class="comment">!&lt; (Element, NeighbourNumber) obs: triangles have 3 neihgbours each</span>
<a name="l00029"></a>00029 
<a name="l00030"></a><a class="code" href="struct_square_triangular_grid_manipulation_1_1_square_triangular_grid.html#a6ddcfa9bb74c0e2d361d64ff565b29d3">00030</a>         <span class="keywordtype">integer</span>, <span class="keywordtype">dimension(:,:)</span>, <span class="keywordtype">allocatable</span>             :: BoundaryEdges
<a name="l00031"></a>00031 <span class="keyword">    end type</span>
<a name="l00032"></a>00032 
<a name="l00033"></a>00033 <span class="keyword">contains</span>
<a name="l00034"></a>00034 
<a name="l00040"></a><a class="code" href="class_square_triangular_grid_manipulation.html#aaf6e05d861021c1e65bd9f5e57f77465">00040</a>         <span class="keywordtype">pure</span> <span class="keyword">function </span>numberOfElements( this ) result ( n )
<a name="l00041"></a>00041                 <span class="keyword">implicit none</span>
<a name="l00042"></a>00042                 <span class="keywordtype">type(SquareTriangularGrid)</span>, <span class="keywordtype">intent(in)</span> :: this
<a name="l00043"></a>00043                 <span class="keywordtype">integer</span> :: n
<a name="l00044"></a>00044                 n = this%Nelx*this%Nely*2
<a name="l00045"></a>00045 <span class="keyword">        end function</span>
<a name="l00046"></a>00046 
<a name="l00047"></a>00047 
<a name="l00053"></a><a class="code" href="class_square_triangular_grid_manipulation.html#abe1a48da3d9911c9d925b6eb559f7cdd">00053</a>         <span class="keywordtype">pure</span> <span class="keyword">function </span>numberOfBoundaryElements( this ) result (n)
<a name="l00054"></a>00054                 <span class="keyword">implicit none</span>
<a name="l00055"></a>00055                 <span class="keywordtype">type(SquareTriangularGrid)</span>, <span class="keywordtype">intent(in)</span> :: this
<a name="l00056"></a>00056                 n = 2*(this%Nelx+this%Nely)
<a name="l00057"></a>00057 <span class="keyword">        end function</span>
<a name="l00058"></a>00058 
<a name="l00059"></a>00059 
<a name="l00060"></a>00060 
<a name="l00071"></a><a class="code" href="class_square_triangular_grid_manipulation.html#a5a2698974de2789f082d4b0e5a0a1d93">00071</a>     <span class="keyword">subroutine </span>SetGridData( this, Lx, Ly, Nelx, Nely, Basex, Basey)
<a name="l00072"></a>00072         <span class="keyword">implicit none</span>
<a name="l00073"></a>00073         <span class="keywordtype">type(SquareGrid)</span>, <span class="keywordtype">intent(out)</span> :: this
<a name="l00074"></a>00074         <span class="keywordtype">real(kind=8)</span>, <span class="keywordtype">intent(in)</span> :: Lx
<a name="l00075"></a>00075         <span class="keywordtype">real(kind=8)</span>, <span class="keywordtype">intent(in)</span> :: Ly
<a name="l00076"></a>00076         <span class="keywordtype">integer</span>, <span class="keywordtype">intent(in)</span> :: Nelx
<a name="l00077"></a>00077         <span class="keywordtype">integer</span>, <span class="keywordtype">intent(in)</span> :: Nely
<a name="l00078"></a>00078         <span class="keywordtype">real(kind=8)</span>, <span class="keywordtype">intent(in)</span> :: Basex
<a name="l00079"></a>00079         <span class="keywordtype">real(kind=8)</span>, <span class="keywordtype">intent(in)</span> :: Basey
<a name="l00080"></a>00080 
<a name="l00081"></a>00081         this%Nelx = Nelx
<a name="l00082"></a>00082         this%Nely = Nely
<a name="l00083"></a>00083         this%Lx = Lx
<a name="l00084"></a>00084         this%Ly = Ly
<a name="l00085"></a>00085         this%Basex = Basex
<a name="l00086"></a>00086         this%Basey = Basey
<a name="l00087"></a>00087 <span class="keyword">    end subroutine</span>
<a name="l00088"></a>00088 
<a name="l00089"></a>00089 
<a name="l00090"></a>00090 
<a name="l00091"></a><a class="code" href="class_square_triangular_grid_manipulation.html#a95adc7869efd8ec72c4c2de907d9217d">00091</a>     <span class="keyword">subroutine </span>GenerateStructuredGrid( this )
<a name="l00092"></a>00092         <span class="keyword">implicit none</span>
<a name="l00093"></a>00093         <span class="keywordtype">type(SquareTriangularGrid)</span>, <span class="keywordtype">intent(inout)</span> :: this
<a name="l00094"></a>00094 
<a name="l00095"></a>00095         call GenerateNodes(this)
<a name="l00096"></a>00096 
<a name="l00097"></a>00097         call GenerateElements(this)
<a name="l00098"></a>00098 
<a name="l00099"></a>00099         call GenerateNeighbours(this)
<a name="l00100"></a>00100 <span class="keyword">    end subroutine</span>
<a name="l00101"></a>00101 
<a name="l00102"></a>00102 
<a name="l00107"></a><a class="code" href="class_square_triangular_grid_manipulation.html#aa5cd0bf56d688d533a75b6a260d1fc54">00107</a>     <span class="keyword">subroutine </span>GenerateNodes( this )
<a name="l00108"></a>00108         <span class="keyword">implicit none</span>
<a name="l00109"></a>00109         <span class="keywordtype">type(SquareTriangularGrid)</span>, <span class="keywordtype">intent(inout)</span> :: this
<a name="l00110"></a>00110 
<a name="l00111"></a>00111         <span class="keywordtype">integer</span> :: i, j
<a name="l00112"></a>00112         <span class="keywordtype">integer</span> :: statReturn
<a name="l00113"></a>00113 
<a name="l00114"></a>00114         <span class="keywordtype">real(kind=8)</span> :: dx, dy
<a name="l00115"></a>00115 
<a name="l00116"></a>00116         <span class="keyword">allocate</span>(this%Nodes( (this%Nelx+1)*(this%Nely+1), 2 ), stat=statReturn )
<a name="l00117"></a>00117         <span class="keyword">if</span>( statReturn /= 0 ) <span class="keyword">then</span>
<a name="l00118"></a>00118             print *, <span class="stringliteral">&#39;Unable to allocate memory for Nodes. NumbNodes = &#39;</span>, (this%Nelx+1)*(this%Nely+1)
<a name="l00119"></a>00119             return
<a name="l00120"></a>00120         <span class="keyword">end if</span>
<a name="l00121"></a>00121 
<a name="l00122"></a>00122         dx = this%Lx/this%Nelx
<a name="l00123"></a>00123         dy = this%Ly/this%Nely
<a name="l00124"></a>00124 
<a name="l00125"></a>00125         forall( i = 1:(this%Nely+1), j = 1:(this%Nelx+1) )
<a name="l00126"></a>00126             this%Nodes( (i - 1)*(this%Nelx+1) + j ,1) = this%Basex + (j-1)*dx
<a name="l00127"></a>00127             this%Nodes( (i - 1)*(this%Nelx+1) + j ,2) = this%Basey + (i-1)*dy
<a name="l00128"></a>00128         <span class="keyword">end</span> forall
<a name="l00129"></a>00129 <span class="keyword">    end subroutine</span>
<a name="l00130"></a>00130 
<a name="l00135"></a><a class="code" href="class_square_triangular_grid_manipulation.html#adf59919241473956bf4992d6526ccc67">00135</a>     <span class="keyword">subroutine </span>GenerateElements(this)
<a name="l00136"></a>00136         <span class="keyword">implicit none</span>
<a name="l00137"></a>00137         <span class="keywordtype">type(SquareGrid)</span>, <span class="keywordtype">intent(inout)</span> :: this
<a name="l00138"></a>00138 
<a name="l00139"></a>00139         <span class="keywordtype">integer</span> :: i, j
<a name="l00140"></a>00140         <span class="keywordtype">integer</span> :: statReturn
<a name="l00141"></a>00141         <span class="keywordtype">integer</span> :: elementCount
<a name="l00142"></a>00142         <span class="keywordtype">integer</span> :: square
<a name="l00143"></a>00143                 <span class="keywordtype">integer</span> :: numberOfGhostElements
<a name="l00144"></a>00144 
<a name="l00145"></a>00145                 numberOfGhostElements = this%Nelx + this%Nely + this%Nelx + this%Nely <span class="comment">!&lt; Number of elements around the perimeter</span>
<a name="l00146"></a>00146 
<a name="l00147"></a>00147         <span class="keyword">allocate</span>(this%Elements(numberOfElements(this)+numberOfGhostElements), stat=statReturn )
<a name="l00148"></a>00148         <span class="keyword">if</span>( statReturn /= 0 ) <span class="keyword">then</span>
<a name="l00149"></a>00149             print *, <span class="stringliteral">&#39;Unable to allocate memory for Elements. NumbElements = &#39;</span>, numberOfElements(this)
<a name="l00150"></a>00150             return
<a name="l00151"></a>00151         <span class="keyword">end if</span>
<a name="l00152"></a>00152                 elementCount = 0
<a name="l00153"></a>00153                 i = 1
<a name="l00154"></a>00154                 j = 1
<a name="l00155"></a>00155         <span class="keyword">do</span> square = 1, this%Nely*this%Nelx <span class="comment">!&lt; Each square of the grid</span>
<a name="l00156"></a>00156                         <span class="comment">!&lt; Setting triangle one</span>
<a name="l00157"></a>00157                         elementCount = elementCount + 1
<a name="l00158"></a>00158                         call SetNodesTriangularElement(this%Elements(elementCount), &amp;
<a name="l00159"></a>00159                                                 (i-1)*(this%Nelx) + j + 1, &amp;  <span class="comment">! SE node</span>
<a name="l00160"></a>00160                                                 (i)  *(this%Nelx) + j + 1, &amp;  <span class="comment">! NW node</span>
<a name="l00161"></a>00161                                                 (i-1)*(this%Nelx) + j )     <span class="comment">! SW node</span>
<a name="l00162"></a>00162             <span class="comment">!this%Elements( elementCount )%Nodes(3) = (i)  *(this%Nelx) + j      ! NE node</span>
<a name="l00163"></a>00163             call <a class="code" href="_square_triangular_grid_8f90.html#a7d405fb532db8e5c6806c868c2b18110">CalculateNormalOuterVector</a>
<a name="l00164"></a>00164             <span class="comment">!&lt; Setting triangle two</span>
<a name="l00165"></a>00165                         elementCount = elementCount + 1
<a name="l00166"></a>00166                         call SetNodesTriangularElement(this%Elements(elementCount), &amp;
<a name="l00167"></a>00167                                                  (i-1)*(this%Nelx) + j, &amp;     <span class="comment">! SW node</span>
<a name="l00168"></a>00168                                                  (i)  *(this%Nelx) + j, &amp;     <span class="comment">! NE node</span>
<a name="l00169"></a>00169                                                  (i)  *(this%Nelx) + j + 1 ) <span class="comment">! NW node</span>
<a name="l00170"></a>00170             <span class="comment">!this%Elements( elementCount )%Nodes(2) = (i-1)*(this%Nelx) + j + 1  ! SE node</span>
<a name="l00171"></a>00171             call <a class="code" href="_square_triangular_grid_8f90.html#a7d405fb532db8e5c6806c868c2b18110">CalculateNormalOuterVector</a>
<a name="l00172"></a>00172             call <a class="code" href="_square_triangular_grid_8f90.html#a7ea41acd06972a49eecbb0e7f1498a4f">CheckNextLine</a>
<a name="l00173"></a>00173         <span class="keyword">end do</span>
<a name="l00174"></a>00174         <span class="keyword">contains</span>
<a name="l00175"></a><a class="code" href="_square_triangular_grid_8f90.html#a7ea41acd06972a49eecbb0e7f1498a4f">00175</a>                 <span class="keyword">subroutine </span><a class="code" href="_square_triangular_grid_8f90.html#a7ea41acd06972a49eecbb0e7f1498a4f">CheckNextLine</a> <span class="comment">!&lt; Maximum number of elements in a line</span>
<a name="l00176"></a>00176                         <span class="keyword">if</span> ( j == this%Nelx ) <span class="keyword">then</span>
<a name="l00177"></a>00177                                 j = 1
<a name="l00178"></a>00178                                 i = i+1
<a name="l00179"></a>00179                         <span class="keyword">end if</span>
<a name="l00180"></a>00180 <span class="keyword">                end subroutine</span>
<a name="l00181"></a><a class="code" href="_square_triangular_grid_8f90.html#a7d405fb532db8e5c6806c868c2b18110">00181</a>                 <span class="keyword">subroutine </span><a class="code" href="_square_triangular_grid_8f90.html#a7d405fb532db8e5c6806c868c2b18110">CalculateNormalOuterVector</a>
<a name="l00182"></a>00182                         call CalculateOuterVector(this%Elements(elementCount), &amp;
<a name="l00183"></a>00183                                                 this%Nodes(this%Elements(elementCount)%Nodes))
<a name="l00184"></a>00184 <span class="keyword">                end subroutine</span>
<a name="l00185"></a>00185 
<a name="l00186"></a>00186 <span class="keyword">    end subroutine</span>
<a name="l00187"></a>00187 
<a name="l00188"></a>00188 
<a name="l00193"></a><a class="code" href="class_square_triangular_grid_manipulation.html#a8bd53345cef65b271e72f528810bc886">00193</a>     <span class="keyword">subroutine </span>GenerateNeighbours(this)
<a name="l00194"></a>00194         <span class="keyword">implicit none</span>
<a name="l00195"></a>00195         <span class="keywordtype">type(SquareGrid)</span>, <span class="keywordtype">intent(inout)</span> :: this
<a name="l00196"></a>00196 
<a name="l00197"></a>00197         <span class="keywordtype">integer</span> :: i, j
<a name="l00198"></a>00198         <span class="keywordtype">integer</span> :: n
<a name="l00199"></a>00199                 <span class="keywordtype">integer</span> :: square
<a name="l00200"></a>00200         <span class="keywordtype">integer</span> :: statReturn
<a name="l00201"></a>00201 
<a name="l00202"></a>00202         <span class="keyword">allocate</span>(this%Neighbours(numberOfElements(this), nNodes), stat=statReturn )
<a name="l00203"></a>00203         <span class="keyword">if</span>( statReturn /= 0 ) <span class="keyword">then</span>
<a name="l00204"></a>00204             print *, <span class="stringliteral">&#39;Unable to allocate memory for Neighbours Elements. NumbNeighElements = &#39;</span>, numberOfElements(this)*nNodes
<a name="l00205"></a>00205             return
<a name="l00206"></a>00206         <span class="keyword">end if</span>
<a name="l00207"></a>00207 
<a name="l00208"></a>00208         this%Neighbours = 0
<a name="l00209"></a>00209 
<a name="l00210"></a>00210         <span class="keyword">do</span> i = 1, this%Nely
<a name="l00211"></a>00211             <span class="keyword">do</span> j = 1, this%Nelx
<a name="l00212"></a>00212                 n = (i-1)*(this%Nelx) + j
<a name="l00213"></a>00213                 <span class="keyword">if</span>(i /= 1)         this%Neighbours(n,1) = (i-2)*(this%Nelx) + j      <span class="comment">! Southern Neighbour</span>
<a name="l00214"></a>00214                 <span class="keyword">if</span>(j /= this%Nelx) this%Neighbours(n,2) = (i-1)*(this%Nelx) + j + 1  <span class="comment">! Eastern Neighbour</span>
<a name="l00215"></a>00215                 <span class="keyword">if</span>(i /= this%Nely) this%Neighbours(n,3) = (i)*(this%Nelx) + j        <span class="comment">! Nothern Neighbour</span>
<a name="l00216"></a>00216                 <span class="keyword">if</span>(j /= 1)         this%Neighbours(n,4) = (i-1)*(this%Nelx) + j - 1  <span class="comment">! Western Neighbour</span>
<a name="l00217"></a>00217             <span class="keyword">end do</span>
<a name="l00218"></a>00218         <span class="keyword">end do</span>
<a name="l00219"></a>00219 <span class="keyword">    end subroutine</span>
<a name="l00220"></a>00220 
<a name="l00221"></a>00221 <span class="comment">!// \todo (ronaldo#1#): Gerar uma forma de alocar corretamente os Elementos Fantasmas</span>
<a name="l00222"></a><a class="code" href="class_square_triangular_grid_manipulation.html#a5116684d42ce1a47448f6183866a6851">00222</a>     <span class="keyword">subroutine </span>GenerateBoundaryEdges(this)
<a name="l00223"></a>00223         <span class="keyword">implicit none</span>
<a name="l00224"></a>00224         <span class="keywordtype">type(SquareGrid)</span>, <span class="keywordtype">intent(inout)</span> :: this
<a name="l00225"></a>00225 
<a name="l00226"></a>00226         <span class="keywordtype">integer</span> :: i, n
<a name="l00227"></a>00227 
<a name="l00228"></a>00228         <span class="keywordtype">integer</span> :: statReturn
<a name="l00229"></a>00229 
<a name="l00230"></a>00230         n = 2*(this%Nelx+this%Nely)
<a name="l00231"></a>00231         <span class="keyword">allocate</span>(this%BoundaryEdges(n,2), stat=statReturn )
<a name="l00232"></a>00232         <span class="keyword">if</span>( statReturn /= 0 ) <span class="keyword">then</span>
<a name="l00233"></a>00233             print *, <span class="stringliteral">&#39;Unable to allocate memory for Boundary Edge Elements. NumbBoundEdges = &#39;</span>, (this%Nelx+this%Nely)*2
<a name="l00234"></a>00234             return
<a name="l00235"></a>00235         <span class="keyword">end if</span>
<a name="l00236"></a>00236 
<a name="l00237"></a>00237         this%BoundaryEdges = 0
<a name="l00238"></a>00238 
<a name="l00239"></a>00239         <span class="keyword">do</span> i = 1, this%Nelx
<a name="l00240"></a>00240             this%BoundaryEdges(i,1) = i
<a name="l00241"></a>00241             this%BoundaryEdges(i+this%Nely,1) = (this%Nelx*this%Nely) - (i-1)
<a name="l00242"></a>00242         <span class="keyword">end do</span>
<a name="l00243"></a>00243         <span class="keyword">do</span> i = 1, this%Nely
<a name="l00244"></a>00244             this%BoundaryEdges(this%Nelx+i,1) = this%Nelx * i
<a name="l00245"></a>00245             this%BoundaryEdges(i+2*this%Nelx+this%Nely ,1) = (this%Nelx*this%Nely) - i * this%Nelx + 1
<a name="l00246"></a>00246         <span class="keyword">end do</span>
<a name="l00247"></a>00247 <span class="keyword">    end subroutine</span>
<a name="l00248"></a>00248 
<a name="l00254"></a><a class="code" href="class_square_triangular_grid_manipulation.html#a4ae92a8d65bdf0bd4e632fbd2538e36a">00254</a>         <span class="keyword">function </span>GhostTriangle( boundaryElement, sharedEdge ) result (Ghost)
<a name="l00255"></a>00255                 <span class="keyword">implicit none</span>
<a name="l00256"></a>00256                 <span class="keywordtype">type(TriangleElement)</span>, <span class="keywordtype">intent(in)</span> :: boundaryElement
<a name="l00257"></a>00257                 <span class="keywordtype">integer</span>, <span class="keywordtype">dimension(2)</span>, <span class="keywordtype">intent(in)</span> :: sharedEdge
<a name="l00258"></a>00258 
<a name="l00259"></a>00259                 <span class="keywordtype">integer</span>, <span class="keywordtype">dimension(MatrixSize)</span>:: Indexes
<a name="l00260"></a>00260 
<a name="l00261"></a>00261                 Ghost % Nodes(1) = 0
<a name="l00262"></a>00262                 Ghost % Nodes(2) = sharedEdge(1)
<a name="l00263"></a>00263                 Ghost % Nodes(3) = sharedEdge(2)
<a name="l00264"></a>00264 
<a name="l00265"></a>00265                 Ghost % Matrix = 0.0d0
<a name="l00266"></a>00266                 Ghost % DoF = 0.0d0
<a name="l00267"></a>00267 
<a name="l00268"></a>00268                 Ghost % NeighbourReNumbering = 0
<a name="l00269"></a>00269                 call SetNeighbourNumbering(Ghost, 1, boundaryElement)
<a name="l00270"></a>00270                 Ghost % S = 0.0d0
<a name="l00271"></a>00271 <span class="keyword">        end function</span>
<a name="l00272"></a>00272 
<a name="l00273"></a>00273 
<a name="l00281"></a><a class="code" href="class_square_triangular_grid_manipulation.html#ad3337bb9e6f06cb3aac125c4f34aae8e">00281</a>         <span class="keyword">subroutine </span>SetGhostData_Convection( Ghost, BoundaryElement, sharedEdge, convectionFactor, EnvironmentTemperature )
<a name="l00282"></a>00282                 <span class="keyword">implicit none</span>
<a name="l00283"></a>00283                 <span class="keywordtype">type(TriangleElement)</span>, <span class="keywordtype">intent(out)</span> :: Ghost
<a name="l00284"></a>00284                 <span class="keywordtype">type(TriangleElement)</span>, <span class="keywordtype">intent(in)</span> :: BoundaryElement
<a name="l00285"></a>00285                 <span class="keywordtype">integer</span>, <span class="keywordtype">dimension(2)</span> :: sharedEdge
<a name="l00286"></a>00286                 <span class="keywordtype">real(kind=8)</span>, <span class="keywordtype">intent(in)</span> :: convectionFactor
<a name="l00287"></a>00287                 <span class="keywordtype">real(kind=8)</span>, <span class="keywordtype">intent(in)</span> :: EnvironmentTemperature
<a name="l00288"></a>00288 
<a name="l00289"></a>00289                 <span class="keywordtype">real(kind=8)</span>, <span class="keywordtype">dimension(2)</span> :: T
<a name="l00290"></a>00290 
<a name="l00291"></a>00291                 T(1) = BoundaryElement%DoF(Temperature_Initial+Ghost%NeighbourReNumbering(1,2)-1, Dof_Commit)
<a name="l00292"></a>00292                 T(2) = BoundaryElement%DoF(Temperature_Initial+Ghost%NeighbourReNumbering(1,3)-1, Dof_Commit)
<a name="l00293"></a>00293 
<a name="l00294"></a>00294                 Ghost % DoF(HeatFluxX_Initial+1) = convectionFactor *(T(1) - EnvironmentTemperature) * Ghost%OuterVector(1,XAxis)
<a name="l00295"></a>00295                 Ghost % DoF(HeatFluxY_Initial+1) = convectionFactor *(T(1) - EnvironmentTemperature) * Ghost%OuterVector(1,YAxis)
<a name="l00296"></a>00296 
<a name="l00297"></a>00297                 Ghost % DoF(HeatFluxX_Initial+2) = convectionFactor *(T(2) - EnvironmentTemperature) * Ghost%OuterVector(1,XAxis)
<a name="l00298"></a>00298                 Ghost % DoF(HeatFluxY_Initial+2) = convectionFactor *(T(2) - EnvironmentTemperature) * Ghost%OuterVector(1,YAxis)
<a name="l00299"></a>00299 
<a name="l00300"></a>00300                 Ghost % DoF(Temperature_Initial+1) = T(1)
<a name="l00301"></a>00301                 Ghost % DoF(Temperature_Initial+2) = T(2)
<a name="l00302"></a>00302 <span class="keyword">        end subroutine</span>
<a name="l00303"></a>00303 
<a name="l00304"></a>00304 
<a name="l00311"></a><a class="code" href="class_square_triangular_grid_manipulation.html#ab40a753ab1d1533eb377b55b518383a0">00311</a>         <span class="keyword">subroutine </span>SetGhostData_PrescribedTemperature( Ghost, BoundaryElement, sharedEdge, Temperature )
<a name="l00312"></a>00312                 <span class="keyword">implicit none</span>
<a name="l00313"></a>00313                 <span class="keywordtype">type(TriangleElement)</span>, <span class="keywordtype">intent(out)</span> :: Ghost
<a name="l00314"></a>00314                 <span class="keywordtype">type(TriangleElement)</span>, <span class="keywordtype">intent(in)</span> :: BoundaryElement
<a name="l00315"></a>00315                 <span class="keywordtype">integer</span>, <span class="keywordtype">dimension(2)</span> :: sharedEdge
<a name="l00316"></a>00316                 <span class="keywordtype">real(kind=8)</span>, <span class="keywordtype">dimension(2)</span>, <span class="keywordtype">intent(in)</span> :: Temperature
<a name="l00317"></a>00317 
<a name="l00318"></a>00318                 <span class="keywordtype">real(kind=8)</span>, <span class="keywordtype">dimension(2,probDim)</span> :: Q
<a name="l00319"></a>00319 
<a name="l00320"></a>00320                 Q(1, XAxis) = BoundaryElement%DoF(HeatFluxX_Initial+Ghost%NeighbourReNumbering(1,2)-1, Dof_Commit)
<a name="l00321"></a>00321                 Q(1, YAxis) = BoundaryElement%DoF(HeatFluxY_Initial+Ghost%NeighbourReNumbering(1,2)-1, Dof_Commit)
<a name="l00322"></a>00322 
<a name="l00323"></a>00323                 Q(2, XAxis) = BoundaryElement%DoF(HeatFluxX_Initial+Ghost%NeighbourReNumbering(1,3)-1, Dof_Commit)
<a name="l00324"></a>00324                 Q(2, YAxis) = BoundaryElement%DoF(HeatFluxY_Initial+Ghost%NeighbourReNumbering(1,3)-1, Dof_Commit)
<a name="l00325"></a>00325 
<a name="l00326"></a>00326                 Ghost % DoF(HeatFluxX_Initial+1) = Q(1,XAxis)
<a name="l00327"></a>00327                 Ghost % DoF(HeatFluxY_Initial+1) = Q(1,YAxis)
<a name="l00328"></a>00328 
<a name="l00329"></a>00329                 Ghost % DoF(HeatFluxX_Initial+2) = Q(2,XAxis)
<a name="l00330"></a>00330                 Ghost % DoF(HeatFluxY_Initial+2) = Q(2,YAxis)
<a name="l00331"></a>00331 
<a name="l00332"></a>00332                 Ghost % DoF(Temperature_Initial+1) = Temperature(1)
<a name="l00333"></a>00333                 Ghost % DoF(Temperature_Initial+2) = Temperature(2)
<a name="l00334"></a>00334 <span class="keyword">        end subroutine</span>
<a name="l00335"></a>00335 
<a name="l00336"></a>00336 
<a name="l00337"></a><a class="code" href="class_square_triangular_grid_manipulation.html#a1d7750f63dff0568d766d0f24b4898f6">00337</a>     <span class="keywordtype">pure</span> <span class="keyword">function </span>MaximumError(this) result (rValue)
<a name="l00338"></a>00338         <span class="keyword">implicit none</span>
<a name="l00339"></a>00339         <span class="keywordtype">type(SquareTriangularGrid)</span>, <span class="keywordtype">intent(in)</span> :: this
<a name="l00340"></a>00340 
<a name="l00341"></a>00341         <span class="keywordtype">integer</span> :: i, nEl
<a name="l00342"></a>00342         <span class="keywordtype">real(kind=8)</span> :: rValue
<a name="l00343"></a>00343 
<a name="l00344"></a>00344         nEl = numberOfElements(this)
<a name="l00345"></a>00345         rValue = 0.0d0
<a name="l00346"></a>00346         <span class="keyword">do</span> i = 1, nEl
<a name="l00347"></a>00347             rValue = max(rValue, SolutionErrorRange(this%Elements[i]))
<a name="l00348"></a>00348         <span class="keyword">end do</span>
<a name="l00349"></a>00349 <span class="keyword">    end function</span>
<a name="l00350"></a>00350 
<a name="l00351"></a><a class="code" href="class_square_triangular_grid_manipulation.html#acf1708ea8b7840dc2dbb379bb0b68994">00351</a>         <span class="keyword">subroutine </span>Step(this)
<a name="l00352"></a>00352                 <span class="keyword">implicit none</span>
<a name="l00353"></a>00353                 <span class="keywordtype">type(SquareTriangularGrid)</span>, <span class="keywordtype">intent(out)</span> :: this
<a name="l00354"></a>00354 
<a name="l00355"></a>00355                 <span class="keywordtype">integer</span> :: i
<a name="l00356"></a>00356         <span class="keywordtype">integer</span> :: stepsDone
<a name="l00357"></a>00357         <span class="keywordtype">real(kind=8)</span> :: maxerr
<a name="l00358"></a>00358 
<a name="l00359"></a>00359         maxerr = 1.0d6
<a name="l00360"></a>00360 
<a name="l00361"></a>00361         <span class="keyword">do</span> <span class="keyword">while</span> (maxerr &gt; MaximumError .or. stepsDone &lt;= MaxSteps)
<a name="l00362"></a>00362             <span class="keyword">do</span> i = 1, NumberOfElements(this)
<a name="l00363"></a>00363                 call StepElement(this%Elements(i), this%Elements(this%Neighbours(i,:)) )
<a name="l00364"></a>00364 
<a name="l00365"></a>00365             <span class="keyword">end do</span>
<a name="l00366"></a>00366         <span class="keyword">end do</span>
<a name="l00367"></a>00367 
<a name="l00368"></a>00368 <span class="keyword">        end subroutine</span>
<a name="l00369"></a>00369 
<a name="l00370"></a>00370 <span class="keyword">end module</span>
</pre></div></div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="_square_triangular_grid_8f90.html">SquareTriangularGrid.f90</a>      </li>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>


    <li class="footer">Generated on Wed Jun 20 2012 15:23:54 for Discontinuous Galerkin by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
